<script>
    export default {
        name: 'CommonList',
        components: {},
        props: {
            dataSource: {
                type: Array,
                default: () => []
            },
            listOptions: {
                type: Object,
                default: () => {}
            }
        },
        data() {
            return {
                columnsOptions: {
                    KeyName: 'id', // 行关键字
                    columns: [],
                    defaultChecked: [], // 默认选中的值
                    bordered: true, // 是否需要边框
                    isNeedIndex: true, // 是否需要序号， 默认要
                    isNeedSelection: true, // 是否需要多选，默认要
                    isNeedPageSize: true, // 是否需要分页， 默认要
                    isNeedOperation: true, // 是否需要操作区
                    isFixedColumns: false, // 是否固定条数
                    pageSize: {
                        current: 1,
                        defaultPageSize: 10,
                        total: 0,
                        showTotal: (total) => `共 ${total} 条`
                    },
                    selectedRow: []
                }
            }
        },
        computed: {
            columns() {
                let columns = []
                if (this.columnsOptions.isNeedIndex) {
                    columns.push({
                        title: '序号',
                        dataIndex: 'sequence_index_number',
                        width: '80px',
                        align: 'center',
                        customRender: (text, record, index) => {
                            return index + 1
                        }
                    })
                }
                columns = columns.concat(this.columnsOptions.columns.map(item => {
                    return {
                        ...item,
                        align: item.align || 'center'
                    }
                }))
                if (this.columnsOptions.isNeedOperation) {
                    const Obj = {
                        title: '操作区',
                        key: 'operation',
                        align: 'center',
                        scopedSlots: { customRender: 'operation' }
                    }
                    if (this.columnsOptions.operWidth) {
                        Object.assign(Obj, {
                            width: this.columnsOptions.operWidth
                        })
                    }
                    if (this.columnsOptions.isfixed) {
                        Object.assign(Obj, {
                            fixed: this.columnsOptions.isfixed
                        })
                    }
                    columns.push(Obj)
                }
                return columns
            },
            rowSelection() {
                return {
                    onSelect: (record, selected) => {
                        selected ? this.selectedRow.push(record) : this.selectedRow.splice(this
